package com.ymttest.database.sqlwapper.hunter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.hunter.ManageFeeConfig;

public class ManageFeeConfigWrapper {
	
	SqlManager manager;

    public ManageFeeConfigWrapper() {
        manager = new SqlManager("tradingsettlement");
    }
    
    @SuppressWarnings("unchecked")
	public ManageFeeConfig selectByPrimaryKey(Long id) {
    	
    	ManageFeeConfig manageFeeConfig = new ManageFeeConfig();
    	List<ManageFeeConfig> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.hunter.ManageFeeConfigMapper.selectByPrimaryKey",
                        id);
        manager.commit();
        
		if (result.size() > 0) {
			manageFeeConfig = result.get(0);
		}
		
        return manageFeeConfig;
    }
    
    //通过费用类型、当前和子hunter等级获取费用信息
   	@SuppressWarnings({ "unchecked", "rawtypes" })
   	public ManageFeeConfig selectConfigByTypeAndHunterLevel(int feeType, int currentHunterLevel, int childHunterLevel) {

   		ManageFeeConfig manageFeeConfig = new ManageFeeConfig();

   		Map m = new HashMap<String, String>();

   		m.put("fee_type", feeType);
   		m.put("current_hunter_level", currentHunterLevel);
   		m.put("child_hunter_level", childHunterLevel);

   		List<ManageFeeConfig> result = manager
   				.getSelectResults(
   						"com.ymttest.database.mapping.hunter.ManageFeeConfigMapper.selectConfigByTypeAndHunterLevel",
   						m);
   		manager.commit();

   		if (result.size() > 0) {
   			manageFeeConfig = result.get(0);
   		}

   		return manageFeeConfig;
   	}
    
    public static void main(String[] args) {
    	
    	ManageFeeConfigWrapper test = new ManageFeeConfigWrapper();
    	System.out.println(test.selectConfigByTypeAndHunterLevel(1, 3, 2).getFee_rate());
    }
}
